home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 201-225 / 214 / runback / amigaline-d1 next >
Text File  |  1995-03-13  |  2KB  |  67 lines

  1.     AMIGALINE #D1,    Matthew Dillon
  2.  
  3.     Disconnecting a program such that you can EndCLI and also allow the
  4.     program to call Execute().
  5.  
  6. Problem:
  7.  
  8.     You want to disconnect a program such that when you RUN <nil: >nil:
  9.     (using the new 1.3 RUN) you can then EndCLI the cli.
  10.  
  11.     This program wants to be able to use Execute() to run other programs. 
  12.     The problem is that Execute() requires a valid pr_ConsoleTask (console)
  13.     or it will freeze.
  14.  
  15. Solution: General
  16.  
  17.     Run <nil: >nil: mycprogram
  18.  
  19.     If using the main() entry point, you can fclose(stderr) to remove
  20.     the reference to "*".  If using the _main() entry point, stdio is
  21.     not setup and thus you do not need to do this (in fact, you can't
  22.     use stdio at all without crashing the computer).
  23.  
  24.     note: being able to fclose(stderr) from the main() entry point 
  25.     works with Aztec C.  I don't know about Lattice.  Aztec always
  26.     does an Open("*", 1006) to setup stderr and this reference must
  27.     be removed.
  28.  
  29.                     --
  30.  
  31.     At this point, you can EndCLI and the cli window goes away.  However,
  32.     the 'mycprogram' cannot call Execute() or otherwise run other 
  33.     external programs for two reasons:
  34.  
  35.         (1) pr_ConsoleTask is still non-NULL and points to the now
  36.             defunct window (i.e. you will cause a task-held requester)
  37.  
  38.         (2) you cannot set pr_ConsoleTask to NULL... Execute() does
  39.             not accept it and freezes up.
  40.  
  41.                     --
  42.  
  43.     So, you must set pr_ConsoleTask to some other valid device.  Guess
  44.     what?  Any device will do except NIL: which isn't a real device.  For
  45.     example, RAM: :
  46.  
  47.         extern APTR DeviceProc();
  48.         proc->pr_ConsoleTask = DeviceProc("ram:");
  49.  
  50.         (assuming RAM: exists)
  51.  
  52.     What does this do?  Any program which tries to open the console will
  53.     actually open the file "RAM:*", as in Open("RAM:*", 1006).  
  54.     Unfortunetly, there is no way to place "*" in anything but the 
  55.     root directory of the device.  This is essentially a garbage file.
  56.  
  57.     But the ultimate goal is achieved ... you can kill the CLI window
  58.     and still arbitrarily run programs from the detached program with
  59.     impunity.
  60.  
  61.     The only possible problem which I have yet to test is when several
  62.     programs try to access RAM:* as their console at the same time.  
  63.     Since the file is openned 1006, other programs trying to Open() it
  64.     will fail while the first programs is still running.  What happens?
  65.  
  66.                             -Matt
  67.